﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Jillzhang.Wcf.HostJIT.Contracts;

namespace Jillzhang.Wcf.HostJIT.Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("press any key when dispatcher service is ok!");
            Console.Read();

            CallCalculator();
            CallActivity();

            CallCalculator();
            CallActivity();
           
            Console.ReadKey(true);
        }

        static void CallCalculator()
        {
            using (ChannelFactory<ICalculator> channelFactory = new ChannelFactory<ICalculator>("Calculator"))
            {
                var channel = channelFactory.CreateChannel();
                using (channel as IDisposable)
                {
                    Console.WriteLine(channel.Add(1, 2).ToString());
                }
            }
        }

        static void CallActivity()
        {
            using (ChannelFactory<IActivity> channelFactory2 = new ChannelFactory<IActivity>("Activity"))
            {
                var channel = channelFactory2.CreateChannel();
                using (channel as IDisposable)
                {
                    channel.Excute();
                }
            }
        }
    }
}
